package org.liveboardgames.agricola.view.component
{
    import org.liveboardgames.agricola.vo.action.Action;
    
    public class ActionImage extends SelectableImage
    {
        private var _action:Action;
        
        public function ActionImage()
        {
            super();
            this.setStyle("horizontalCenter", "0");
            this.setStyle("verticalCenter", "0");
        }
        
        override public function set width(value:Number):void
        {
            super.width = value;
            super.height = value;
        }
        
        override public function set height(value:Number):void
        {
            super.width = value;
            super.height = value;
        }
        
        public function set action(value:Action):void
        {
            this._action = value;
            updateSource();
        }
        
        public function get action():Action
        {
            return this._action;
        }
        
        private function updateSource():void
        {
            if (_action != null)
            {
                this.source = getImage(_action);
                this.toolTip = _action.name;
            }
        }
        
        private function getImage(action:Action):String
        {
            trace("Need to define one image per action that can be chosen");
            return ImageHandler.IMAGE_ROOT_PATH + "common/farm/field.png";
        }
    }
}